#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n, m;
int ans[5] = {0, 0, 0, 2, 6};
int v[5] = {1, 1, 4, 2, 6};
void matmul(ll a[5][5], ll b[5][5], ll c[5][5]) {
  ll res[5][5] = {0};
  rep(i, 0, 4) rep(j, 0, 4) rep(k, 0, 4) {
    res[i][j] = (res[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
  }
  rep(i, 0, 4) rep(j, 0, 4) c[i][j] = res[i][j];
}
void matpow(ll b[5][5], ll p, ll c[5][5]) {
  ll res[5][5] = {0};
  rep(i, 0, 4) res[i][i] = 1;
  while (p) {
    if (p & 1) matmul(res, b, res);
    matmul(b, b, b);
    p >>= 1;
  }
  rep(i, 0, 4) rep(j, 0, 4) c[i][j] = res[i][j];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    if (n <= 4) {
      cout << ans[n] << endl;
      continue;
    }
    ll a[5][5] = {
        {0, 1, 0, 0, 0}, {1, 1, 0, 0, 0}, {2, 2, 1, 0, 0},
        {0, 0, 0, 0, 1}, {2, 2, 1, 1, 1},
    };
    matpow(a, n - 4, a);
    ll ans = 0;
    rep(i, 0, 4) ans = (ans + a[4][i] * v[i] % MOD) % MOD;
    cout << ans << endl;
  }
  return 0;
}